/**
 * Created by shanyun.gu on 2017/3/20.
 */
define(['ngApp', 'ngValidate', "jquery", 'ngHttp','swiper'], function (ngApp, ngValidate, $,ngHttp,swiper) {
    ngApp.controller("homeCtrl",['$scope','$state','$rootScope','$http','$timeout', function ($scope,$state,$rootScope,$http,$timeout) {
        //       ngHttp('json/banner.json','post',function(res){
        //           $scope.datas=res.infor;
        //        console.log( $scope.datas)
        //
        //       });
        //console.log(111111)

        //banner
        $http({
            url:'http://localhost:8080/YJNH/wx/homepage/getBannerList',
            method:'POST'
        }).success(function(data,header,config,status){
            //console.log(data)
            $scope.data=data.infor;
            //响应成功
            homeCarousel();

        }).error(function(data,header,config,status){
            //处理响应失败
        });
        //三农动态
        $http({
            url:'http://localhost:8080/YJNH/wx/homepage/getSanNongTitleList',
            method:'POST'
        }).success(function(data,header,config,status){
            $scope.snnews=data.infor;
            homeCarousel();
        }).error(function(data,header,config,status){
            //处理响应失败
        });

        //粮票超值
        $http({
            url:'http://localhost:8080/YJNH/wx/homepage/getLPCZTypes',
            method:'POST'
        }).success(function(data,header,config,status){
            $scope.reducePrice=data.infor;
            homeCarousel();
        }).error(function(data,header,config,status){
            //处理响应失败
        });

        //推荐产品
        $http({
            url:'http://localhost:8080/YJNH/wx/homepage/getRecommendedProducts',
            method:'POST'
        }).success(function(data,header,config,status){
            $scope.recommend=data.infor;
            homeCarousel();
        }).error(function(data,header,config,status){
            //处理响应失败
        });

        //推荐服务+
        $http({
            url:'http://localhost:8080/YJNH/wx/homepage/getRecommendedServices',
            method:'POST'
        }).success(function(data,header,config,status){
            $scope.tjservice=data.infor;
            homeCarousel();
        }).error(function(data,header,config,status){
            //处理响应失败
        });

        //swiper
        function homeCarousel() {
            $timeout(function () {
                //banner
                var swiper = new Swiper('.swiper-container', {
                    pagination: '.swiper-pagination',
                    loop: true, //循环
                    slidesPerView: 'auto',
                    loopedSlides: 3,
                    loopAdditionalSlides: 1,//首尾切换
                    paginationClickable: true,
                    autoHeight: true,
                    autoplay: 2000,
                    autoplayDisableOnInteraction: false //触摸滑动不禁止自动轮播
                });
                //sannong-xinwen
                var swiper = new Swiper('.swiper-container-homeNews', {
                    paginationClickable: true,
                    direction: 'vertical',
                    loop: true,
                    autoplay: 1000,
                });
                //粮票超值
                var swiper = new Swiper('.food_stamps_scrol', {
                    slidesPerView: 5,
                    paginationClickable: true,
                    spaceBetween: 5
                });
                //推荐产品
                var swiper = new Swiper('.home_product_list', {
                    slidesPerView: 3,
                    paginationClickable: true,
                    spaceBetween: 5
                });
            }, 0);
        };
    }]);


});


























